module.exports = function ($scope, $resource, $modalInstance, addedSys, toaster){
    
    $resource('/api/as/sc/sysdocking/openDockingList', {}, {}).save({}, function (res) {
        if (res.errcode === 0){
            $scope.sysList = res.data;
            for(var i = 0; i < res.data.length; i++){
                if(addedSys.indexOf(res.data[i].docking_system_id) == -1){
                    res.data[i].check = true;
                } else {
                    res.data[i].check = false;
                }
            }
        } else {
            toaster.error({title: '', body: res.errmsg});
        }
    });

    $scope.add = function(sys, info){
        var para = {
            'docking_system_id': sys.docking_system_id,
            'company_code': info.company_code,
            'state': '1'
        }
        $resource('/api/as/sc/sysdocking/insertCompanyUser', {}, {}).save(para, function (res){
            if (res.errcode === 0) {
                toaster.success({title: '', body: '操作成功'});
                $modalInstance.close();
            } else {
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }

};